package com.base.taskreports.common.utlis;

import net.lingala.zip4j.core.ZipFile;
import net.lingala.zip4j.exception.ZipException;
import net.lingala.zip4j.model.FileHeader;

import java.io.File;
import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.springframework.util.StringUtils;


/**
 */
public class ThresholdUtlis {


    public static void main(String[] args) throws IOException {
    	String expression = null;
    	  expression = " Value >= -0.1 && Value <= 0.1 " ;
    	// expression =  "Value < 1";
    	// expression =  "Value == 1";
    	// expression =  "Value >= 0.96";
    	// expression =  "Value <= 8000";
   	     String[] split = expression.split("Value");
   	     String end = ")";
   	     String replace = null;
   	     if(split.length != 0 && split.length ==3 ) {
   	    	replace =split[1].replace(">=", "(");
   	    	replace =replace.replace("&&", ",");
   	    	String replace1 = split[2].replace("<=", "");
   	    	String as =  replace + replace1 +end;
   	    	System.out.println(as);
   	     }else if(split.length != 0 && split.length ==2) {
   	    	replace =split[1].replace(">=", "(");
   	    	replace =replace.replace("<=", "(");
   	    	replace =replace.replace(">", "(");
   	    	replace =replace.replace("<", "(");
   	    	replace =replace.replace("==", "(");
   	    	replace =replace.replace("=", "(");
   	    	String as =  replace +end;
   	    	System.out.println(as);
   	     }
    }
    /**
     * 按指定的格式 ，把Value >= -0.1 && Value <= 0.1 " 转换成(-0.1,0.1)
     * 
     * @throws ParseException
     */
    public static String setThresholdValue(String threshold){
       // if (StringUtils.isEmpty(threshold)) {
        	 String[] split = threshold.split("Value");
       	     String end = ")";
       	     String replace = null;
       	     if(split.length != 0 && split.length ==3 ) {
       	    	replace =split[1].replace(">=", "(");
       	    	replace =replace.replace("&&", ",");
       	    	String replace1 = split[2].replace("<=", "");
       	    	String as =  replace + replace1 +end;
       	    	//System.out.println(as);
       	     return as.replaceAll("\\s*", "");
       	     }else if(split.length != 0 && split.length ==2) {
       	    	replace =split[1].replace(">=", "(");
       	    	replace =replace.replace("<=", "(");
       	    	replace =replace.replace(">", "(");
       	    	replace =replace.replace("<", "(");
       	    	replace =replace.replace("==", "(");
       	    	replace =replace.replace("=", "(");
       	    	String as =  replace +end;
       	    	//System.out.println(as);
       	     return as.replaceAll("\\s*", "");
       	     }
       // }
        return threshold;
    }
    
}
